package com.zhuoya.healthcard;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.zhuoya.healthcard.entity.DeliveryInfo;
import com.zhuoya.healthcard.util.ToastUtil;
import com.zhuoya.healthcard.util.ValidateUtils;


public class DeliveryInfoActivity extends BaseActity {
    private String address;
    private String expressMoney;
    private String idCard;
    private DeliveryInfo info;
    private EditText mAddress;
    private TextView mMedicalName;
    private TextView mPay;
    private EditText mPhone;
    private EditText mReceiptName;
    private String medicalName;
    private TextView mexpressMoney;
    private String phone;
    private String receiptName;
    private int registrationId;

    private void initView() {
        this.mMedicalName = this.findViewById(R.id.textView22);
        this.mReceiptName = this.findViewById(R.id.textView23);
        this.mAddress = this.findViewById(R.id.textView25);
        this.mPhone = this.findViewById(R.id.textView24);
        this.mexpressMoney = this.findViewById(R.id.textView26);
        final TextView mexpressMoney = this.mexpressMoney;
        final StringBuilder sb = new StringBuilder();
        sb.append(this.expressMoney);
        sb.append("￥");
        mexpressMoney.setText((CharSequence) sb.toString());
        this.mMedicalName.setText((CharSequence) this.medicalName);
        this.mReceiptName.setText((CharSequence) this.receiptName);
        final DeliveryInfo info = this.info;
        if (info != null) {
            this.mMedicalName.setText((CharSequence) info.getMedicalName());
            this.mReceiptName.setText((CharSequence) this.info.getReceiptName());
            this.mPhone.setText((CharSequence) this.info.getPhone());
            this.mAddress.setText((CharSequence) this.info.getAddress());
        }
        (this.mPay = this.findViewById(R.id.textView12)).setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                final DeliveryInfoActivity this$0 = DeliveryInfoActivity.this;
                this$0.phone = this$0.mPhone.getText().toString();
                final DeliveryInfoActivity this$2 = DeliveryInfoActivity.this;
                this$2.address = this$2.mAddress.getText().toString();
                final DeliveryInfoActivity this$3 = DeliveryInfoActivity.this;
                this$3.receiptName = this$3.mReceiptName.getText().toString();
                if (!ValidateUtils.isMobile(DeliveryInfoActivity.this.phone)) {
                    ToastUtil.show(DeliveryInfoActivity.this, "请输入正确的手机号");
                    return;
                }
                if (DeliveryInfoActivity.this.address == null || "".equals(DeliveryInfoActivity.this.address)) {
                    ToastUtil.show(DeliveryInfoActivity.this, "请输入正确的收件地址");
                    return;
                }
                if (DeliveryInfoActivity.this.receiptName != null && !"".equals(DeliveryInfoActivity.this.receiptName)) {
                    final Intent intent = new Intent(DeliveryInfoActivity.this, PayActivity.class);
                    final Bundle bundle = new Bundle();
                    final DeliveryInfo deliveryInfo = new DeliveryInfo();
                    deliveryInfo.setPhone(DeliveryInfoActivity.this.phone);
                    deliveryInfo.setAddress(DeliveryInfoActivity.this.address);
                    deliveryInfo.setMedicalName(DeliveryInfoActivity.this.medicalName);
                    deliveryInfo.setReceiptName(DeliveryInfoActivity.this.receiptName);
                    deliveryInfo.setIdCard(DeliveryInfoActivity.this.idCard);
                    deliveryInfo.setRegistrationId(DeliveryInfoActivity.this.registrationId);
                    deliveryInfo.setExpressMoney(DeliveryInfoActivity.this.expressMoney);
                    bundle.putSerializable("deliveryInfo", deliveryInfo);
                    intent.putExtras(bundle);
                    DeliveryInfoActivity.this.startActivity(intent);
                    DeliveryInfoActivity.this.finish();
                    return;
                }
                ToastUtil.show(DeliveryInfoActivity.this, "请输入收件人姓名");
            }
        });
        this.findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                final DeliveryInfoActivity this$0 = DeliveryInfoActivity.this;
                this$0.startActivity(new Intent(this$0, MainActivity.class));
                DeliveryInfoActivity.this.finish();
            }
        });
        this.findViewById(R.id.backTV).setOnClickListener(new View.OnClickListener() {
            public void onClick(final View view) {
                final DeliveryInfoActivity this$0 = DeliveryInfoActivity.this;
                this$0.startActivity(new Intent(this$0, MainActivity.class));
                DeliveryInfoActivity.this.finish();
            }
        });
    }

    @Override
    protected void onCreate(final Bundle bundle) {
        super.onCreate(bundle);
        final Intent intent = this.getIntent();
        this.medicalName = intent.getStringExtra("name");
        this.idCard = intent.getStringExtra("idCard");
        this.registrationId = intent.getIntExtra("registrationId", 0);
        this.expressMoney = intent.getStringExtra("expressMoney");
        this.info = (DeliveryInfo) intent.getSerializableExtra("info");
        this.receiptName = this.medicalName;
        this.setContentView(R.layout.activity_delivery_info);
        this.initView();
    }
}
